"use strict";

function _toConsumableArray(r) {
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread()
}

function _nonIterableSpread() {
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
}

function _unsupportedIterableToArray(r, t) {
  if (r) {
    if ("string" == typeof r) return _arrayLikeToArray(r, t);
    var e = Object.prototype.toString.call(r).slice(8, -1);
    return "Object" === e && r.constructor && (e = r.constructor.name), "Map" === e || "Set" === e ? Array.from(r) : "Arguments" === e || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e) ? _arrayLikeToArray(r, t) : void 0
  }
}

function _iterableToArray(r) {
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r)
}

function _arrayWithoutHoles(r) {
  if (Array.isArray(r)) return _arrayLikeToArray(r)
}

function _arrayLikeToArray(r, t) {
  (null == t || t > r.length) && (t = r.length);
  for (var e = 0, n = new Array(t); e < t; e++) n[e] = r[e];
  return n
}
module.exports = {
  name: "Line",
  handler: function () {
    var a = this,
      i = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {};
    return new Promise(function (r, t) {
      var e = i.lineStyle,
        n = i.line,
        o = void 0 === n ? [] : n;
      a.setLineStyle(e), o.forEach(function (r, t) {
        var e, n;
        t ? ((e = a.ctx).lineTo.apply(e, _toConsumableArray(r.point.map(function (r) {
          return a.xDpr(r)
        }))), a.ctx.stroke()) : (a.ctx.beginPath(), (n = a.ctx).moveTo.apply(n, _toConsumableArray(r.point.map(function (r) {
          return a.xDpr(r)
        }))))
      }), r()
    })
  }
};